package game.model.impl

import game.Config
import game.business.AttackAble
import game.business.BlockAble
import game.business.DestroyAble
import game.business.SufferAble
import game.model.View
import org.itheima.kotlin.game.core.Composer
import org.itheima.kotlin.game.core.Painter

/**
 * 墙
 *
 * 具备阻塞能力
 * 具备被攻击能力
 * 具备销毁能力
 */
class Wall(override val x: Int, override val y: Int) : BlockAble,SufferAble,DestroyAble{
/*    override val x: Int = 100
    override val y: Int = 100*/

    override var width: Int = Config.block
    override var height: Int = Config.block

    override var blood: Int = Config.WallBlood

    override fun draw() {
        Painter.drawImage("img/wall.gif",x,y)
    }

    override fun isDestroyed(): Boolean = blood <= 0



    override fun notifySuffer(attackAble: AttackAble):Array<View>?{
        //墙被攻击，需要掉血
        blood -= attackAble.attackPower

        //被攻击后播放声音
        Composer.play("snd/hit.wav")

        return arrayOf(Blast(x,y))
    }


/*    //位置
    var x:Int = 100
    var y:Int = 100

    //宽高
    var width:Int = Config.block
    var height:Int = Config.block

    //显示
    fun draw(){
        Painter.drawImage("img/walls.gif",100,100)
    }*/
}